<?php
namespace Admin\Controller;
use Think\Controller;
class WidgetController extends CommonController {
    public function index()
    {
        $tmp_dir = "Install/Widget/";
        $volist = array();
        $list = scandir($tmp_dir);
        foreach($list as $tpl_name){
            $tpl_dir = $tmp_dir."/".$tpl_name;
            if (!is_dir($tpl_dir)) continue;
            $manifest = $tpl_dir = $tmp_dir."/".$tpl_name.'/manifest.xml';
            if (!file_exists($manifest)) continue;
            $preview = $tpl_dir = $tmp_dir."/".$tpl_name.'/preview.jpg';
            if (!file_exists($preview)) continue;
            $vo = json_decode(json_encode((array) simplexml_load_file($manifest,'SimpleXMLElement', LIBXML_NOCDATA )), true);
            $vo['preview'] = $preview;
            $volist[] = $vo;
        }
        $this->assign('volist',$volist);
        $this->display();
    }
}